<?php
/* @var $this ServicesController */
/* @var $model Services */
/* @var $form TbActiveForm */
?>
<link rel="stylesheet" href="<?php echo Yii::app()->theme->baseUrl; ?>/assets/css/magicsuggest-1.3.1.css">
<script type="text/javascript" src="<?php echo Yii::app()->theme->baseUrl; ?>/assets/js/magicsuggest-1.3.1.js"></script>
<div class="form">

	<?php
	$form = $this->beginWidget('bootstrap.widgets.TbActiveForm', array(
		'id' => 'services-form',
		// Please note: When you enable ajax validation, make sure the corresponding
		// controller action is handling ajax validation correctly.
		// There is a call to performAjaxValidation() commented in generated controller code.
		// See class documentation of CActiveForm for details on this.
		'enableAjaxValidation' => true,
		'clientOptions' => array(
			'validateOnSubmit' => true,
		),
	));
	?>


	<?php echo $form->errorSummary($model); ?>

	<?php echo $form->dropDownListControlGroup($model, 'serviceCategory', CHtml::listData(Page::model()->findAll("\"pageType\" = 'category'"), 'pageId', 'pageTitle'), array('id' => 'source', 'style' => 'width:40%')); ?> 

	<?php echo $form->textFieldControlGroup($model, 'serviceTitle', array('span' => 5, 'maxlength' => 255)); ?>

	<?php echo $form->dropDownListControlGroup($model, 'serviceWarranty', array('1 мес' => '1 мес', '2 мес' => '2 мес', '3 мес' => '3 мес', '6 мес' => '6 мес', '9 мес' => '9 мес', '1 год' => '1 год', '3 года' => '3 года', '5 лет' => '5 лет'), array('id' => 'source', 'style' => 'width:40%')); ?>

	<?php echo $form->dropDownListControlGroup($model, 'serviceType', CHtml::listData(ServTypes::model()->findAll(), 'servTypeId', 'servTypeTitle'), array('id' => 'source', 'style' => 'width:40%')); ?>              

	<?php echo $form->textFieldControlGroup($model, 'serviceTime', array('span' => 5, 'maxlength' => 20)); ?>

	<?php echo $form->textAreaControlGroup($model, 'serviceDescription', array('class' => 'span8')); ?>

	<?php echo $form->textFieldControlGroup($model, 'serviceParts', array('span' => 5, 'maxlength' => 255, 'id' => 'ms-cats')); ?>
    <script>
		$(document).ready(function() {
			var ms = $('#ms-cats').magicSuggest({
				name: 'Services[serviceParts]',
				width: 350,
				//sortOrder: 'title',
				selectionStacked: false,
				selectionPosition: 'right',
				displayField: 'title',
				value: [],
				data: <?php echo $model->getParts(); ?>
			});
		});
	</script>
	<div class="clear"></div><br /><br />

	<div class="form-actions" style="padding-left: 28px;">
		<?php
		echo TbHtml::submitButton($model->isNewRecord ? 'Create' : 'Save', array(
			'color' => TbHtml::BUTTON_COLOR_PRIMARY,
			'size' => TbHtml::BUTTON_SIZE_LARGE,
		));
		?>
    </div>

	<?php $this->endWidget(); ?>

</div><!-- form -->
<hr />
<br />
<?php
$this->widget('bootstrap.widgets.TbGridView', array(
	'id' => 'services-grid',
	'dataProvider' => $modelS->search(),
	'filter' => $modelS,
	'columns' => array(
		'serviceId',
		'serviceTitle',
		'serviceWarranty',
		'serviceTime',
		array(
			'class' => 'bootstrap.widgets.TbButtonColumn',
		),
	),
));
?>